﻿using Coder.Workflow;
using Coder.Workflow.Stores;
using Coder.Workflow.Stores.Ef;
using Microsoft.Extensions.DependencyInjection;

namespace Coder
{
    public static class WorkflowExtentions
    {
        public static IServiceCollection AddWorkflow<T>(this IServiceCollection services
        )
            where T : WorkflowDbContext
        {
            //工作相关
            //  services.AddScoped<DelegateOrderInstanceManager>();
            services
                .AddScoped<IWorkActivityStore<T>, WorkActivityStore<T>>()
                .AddScoped<IProcessInstanceStore<T>, ProcessInstanceStore<T>>()
                .AddScoped<IWorkProcessStore<T>, WorkProcessStore<T>>()
                ;


            return services;
        }

        public static IServiceCollection AddWorkflowType<TWorkflowManager, TDbContext, TProcessInstance>(
            this IServiceCollection services)
            where TWorkflowManager : WorkflowManager<TDbContext, TProcessInstance>
            where TProcessInstance : ProcessInstance
            where TDbContext : WorkflowDbContext

        {
            services
                .AddScoped<TWorkflowManager>();
            return services;
        }
    }
}